<extend name="../app/Admin/View/default/common/dashboard_layout.html"/>
<block name="content">
<section class="content-header clearfix">
    <h1 class="pull-left">短信详情</h1>
    <div class="pull-right">
        <a class="btn btn-primary btn-sm" href='{:addons_url("SmsBatchSend://SmsBatch/sendSms", array("log_id" => $vo["id"]))}'>转发给其他人</a>
        <a class="btn btn-primary btn-sm" href='{:addons_url("SmsBatchSend://SmsBatch/smsLog")}'>返回</a>
    </div>
</section>

<section class="content" n-id="{$log_id}">
<div class='row'>
    <div class="col-xs-12">
        <div class="box box-solid">
            <div class="box-body">
                <div class="row">
                    <div class='col-md-12'>
                        <div class="progress progress-normal">
                            <div class="progress-bar progress-bar-success" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width: {$success_rate}%">成功 {:round($success_rate,2)}%</div>
                            <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width:{$fail_rate}%"> 失败 {:round($fail_rate,2)}%</div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="row">
                            <div class='col-md-4'>
                                <!-- <p>未发送: {$unsend_num}</p> -->
                                <div>
                                    <span class="mail_stat_num">{$unsend_num}</span>
                                </div>
                                <div>
                                    <span>未发送</span>
                                </div>
                            </div>
                            <div class='col-md-4'>
                                <!-- <p>已接收: {$success_num}</p> -->
                                <div>
                                    <span class="mail_stat_num">{$success_num}</span>
                                </div>
                                <div>
                                    <span>已接收</span>
                                </div>
                            </div>
                            <div class='col-md-4'>
                                <!-- <p>发送失败: {$fail_num}</p> -->
                                <div>
                                    <span class="mail_stat_num">{$fail_num}</span>
                                </div>
                                <div>
                                    <span>发送失败</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="mt-20" style="border-top: 1px solid #ccc;padding-top: 20px;">
                            <div class="row">
                                <div class='col-md-6'>
                                    <h2 class="subtitle">
                                        短信信息
                                    </h2>
                                    <p>
                                        收件人  共 {$total}个
                                    </p>
                                    <p>
                                        <span style="color:gray">短信内容</span> {$vo.body}
                                    </p>
                                </div>
                                <div class='col-md-6'>
                                    <h2 class="subtitle">发送结果</h2>
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th>收信手机</th>
                                                <th>姓名</th>
                                                <th>状态</th>
                                                <th>错误原因</th>
                                                <th>回复</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <volist name="d_list" id="d">
                                            <tr>
                                                <td><eq name='d.status' value='发送失败'><a href="#" class="edit_mobile" data-pk="{$d.id}">{$d.mobile}</a><else/>{$d.mobile}</eq></td>
                                                <td>{:getUserRealNameByMobile($d['mobile'])}</td>
                                                <td>{$d.status}</td>
                                                <td>{$d.error_msg}</td>
                                                <td>{$d.rely}</td>
                                                <td><eq name='d.status' value='发送失败'><a href='#' class="resend" data-id="{$d.id}">重发</a></eq></td>
                                            </tr>
                                        </volist>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</section>

<link href="__PUBLIC__/libs/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet">
<script src="__PUBLIC__/libs/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script>
$(function(){ 
    $('.resend').on('click', function(){
        var d_id = $(this).data('id');
        ajaxlink($(this), "{:addons_url('SmsBatchSend://SmsBatch/resend')}?d_id=" + d_id);
    });
    
    $.fn.editable.defaults.mode = 'inline';
    $('.edit_mobile').editable({
        type: 'text',
        url: "{:addons_url('SmsBatchSend://SmsBatch/changeMobileOfDetail')}",
        success: function(response, newValue) {
            console.log(response);
            if(response.status == 0) return response.info; //msg will be shown in editable form
        }
    });
});
</script>
</block>